<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../common/common.jsp"%>  
        <link rel="stylesheet" href="${ctx }/css/layui.css">
		<script type="text/javascript" src="${ctx }/js/layer-v1.9.2/layer/layer.js"></script>
<script type="text/javascript" src="${ctx}/js/layer-v1.9.2/layer/layui.js"></script>     
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>系统正在处理</title>
		<style>			
			div{position:relative;width: 678px;margin:200px auto;}
			p{position: absolute;top: 200px;/* left: 0px; */ font-size: 30px;}
		</style>
		<script type="text/javascript">
		   var orderId = "${param.orderId}";
		   var orderPayDetailInternal; //查询订单支付结果定时器
		   $(function(){
			        orderPayDetailInternal = self.setInterval("orderPayDetail()", 1000);
					 startTime=new Date();
		   });

		 //请求订单支付结果
		 function  orderPayDetail(){
		 	var nowTime = new Date();
		 	if((nowTime.getTime() - startTime.getTime())/1000 >60){ //如果超过1分钟则记为超时
	 			layer.msg("系统请求超时",{offset: ['50%', '40%'],title: ['提醒', 'font-size:18px;']});
		 		//请求支付失败跳转到订单待付款页面
		 		window.location.href=rootPath + '/order/orderPage?queryStatus=1'; //待付款页面
		 	}
		 	var url = rootPath + "/order/payDetail";
		 	var result = CommnUtil.ajax(url,{"orderId":orderId},"json");
		 	if(result.resultSuccess){
		 		if(result.status == '1'  || result.status == '6') {//支付状态1:支付成功,2:支付失败;3:未支付;4:处理异常;5:非法参数;6:银行已经受理,7:已付款至担保方;8:超时;9:准备中; 
		 			window.clearInterval(orderPayDetailInternal);//清除定时器
		 			var $url = rootPath + '/order/pay_success';
		 			window.open($url,'_self');
		 		}else if(result.status == '2'){			   
		 		/* 	layer.msg("请求支付失败",{offset: ['50%', '40%'],title: ['提醒', 'font-size:18px;'],icon: 1,time:100000});
		 			var $url = rootPath + '/order/orderPage?queryStatus=1';
		 			window.open($url,'_self'); */
		 		}else if(result.status == '3'){
		 			/* layer.msg("支付未完成",{offset: ['50%', '40%'],title: ['提醒', 'font-size:18px;'],icon: 1,time:100000});
		 			var $url = rootPath + '/order/orderPage?queryStatus=1'; */
		 		}
		 	}
		 }
		</script>
	</head>
	<body>
		<div class="loading">
			<p>系统正在处理</p>
			<img src="${ctx }/images/loading.gif" alt="" />
		</div>
	</body>
</html>

